from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
from pymouse import *
from pykeyboard import PyKeyboard

driver = webdriver.Chrome() #实例化浏览器对象
driver.implicitly_wait(5)
driver.get("http://192.168.121.128:8080/woniusales/")  #发送访问WoniuSales的请求
assert driver.find_element_by_xpath("//div[1]/div[1]/div[1]/div[1]").is_displayed()  #断言是否进入蜗牛进销存登录页面

driver.find_element_by_id("username").send_keys("admin")   #输入用户名
driver.find_element_by_id("password").send_keys("admin123")  #输入密码
driver.find_element_by_id("verifycode").send_keys("0000")     #输入验证码
driver.find_element_by_xpath("//html/body/div[4]/div/form/div[6]/button").click()  #点击登录

assert driver.find_element_by_xpath("//*[@id='navbar']/ul[2]/li[2]/a").is_displayed()==True    #断言是否登录成功
driver.find_element_by_id("barcode").send_keys("6955203659590")     #输入条码
driver.find_element_by_xpath("//div/div/div/form/button").click()   #点击确认
time.sleep(3)
# Select(driver.find_element_by_id("goodssizeList")).select_by_value("尺码:80,剩余:1件")
# driver.find_element_by_xpath("//tr/td[6]/input").clear()         #清空折扣输入框
# driver.find_element_by_xpath("//tr/td[6]/input").send_keys(55)      #修改折扣
Select(driver.find_element_by_id("paymethod")).select_by_value("刷卡")     #修改付款方式
driver.find_element_by_id("customerphone").send_keys("18091230219")       #输入会员手机号
time.sleep(5)
# driver.find_element_by_xpath('//*[@id="vipsell"]/div[1]/form/div[2]/button').click()  #点击查询会员信息

time.sleep(5)
driver.find_element_by_xpath("//form/div[8]/input").click()   # 点击确认收款

# time.sleep(5)
# content=driver.switch_to.alert.text        #获取弹出框的文本内容
# print(content)

# driver.switch_to.alert.accept()
# driver.quit()  #关闭窗口
time.sleep(3)
k = PyKeyboard()
k.press_key(k.enter_key)


